package ch.wanandroid.lib.database;

import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.content.Context;

import ch.wanandroid.lib.net.beans.BannerDao;
import ch.wanandroid.lib.net.beans.BannerResponse;

/**
 * Author: ch
 * Date: 2018/10/23 16:23
 * Description: ${DESCRIPTION}
 */
@Database(entities = {BannerResponse.Banner.class}, version = 1,exportSchema = false)
public abstract class BannerResponseDatabase extends RoomDatabase {

    private static final String DB_NAME = "BannerResponse.db";
    private static volatile BannerResponseDatabase instance;

    public static synchronized BannerResponseDatabase getInstance(Context context) {
        if (instance == null) {
            instance = create(context);
        }
        return instance;
    }

    private static BannerResponseDatabase create(final Context context) {
        return Room.databaseBuilder(
                context,
                BannerResponseDatabase.class,
                DB_NAME).build();
    }


    public abstract BannerDao getBannerResponseDao();

}
